package Interface;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JFrame;
import javax.swing.JSplitPane;

import xmlItunes.Bibliotheque;

public class FrameDemo extends JFrame  implements KeyListener{

	private static final long serialVersionUID = 1L;
	private JSplitPane jSplitPane = null;
	private panelOutils panelOutils  ;
	private TabbedpanelDroite tabbedpanelDroite;
	
	private Bibliotheque saBib ;
	
	 
	/**
	 * This is the default constructor
	 */
	public FrameDemo() {
		super();
		this.addKeyListener(this);
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		Dimension resolEcran  = Toolkit.getDefaultToolkit().getScreenSize();
		this.setSize(resolEcran);
		
		//On consturtrit la bibliotheque tout au debut 
		saBib = new Bibliotheque();
		tabbedpanelDroite = new TabbedpanelDroite(this);
		panelOutils = new panelOutils(this);
		
		//par defaut on coche la premiere case des genres :
		getPanelOutils().cocherNPremieresCasesGenre(1);
		
		
		this.setContentPane(getJSplitPane());
		this.setTitle("iVisu");
		
		
	}

	/**
	 * This method initializes jSplitPane	
	 * 	
	 * @return javax.swing.JSplitPane
	 */
	public JSplitPane getJSplitPane() {
		if (jSplitPane == null) {
			jSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
					panelOutils,tabbedpanelDroite );			
		}
		jSplitPane.setDividerLocation(260);
	
		return jSplitPane;
	}

	@Override
	public void keyPressed(KeyEvent k) {
	
		if (k.getKeyChar() == KeyEvent.VK_F1) {
			getTabbedpanelDroite().getPanelUnivers().setCentreX(this.getWidth()/2);
			getTabbedpanelDroite().getPanelUnivers().setCentreY(this.getHeight()/2);
			getTabbedpanelDroite().getPanelUnivers().setZoom(PanelUnivers.ZOOM_NIVEAU1);
			getTabbedpanelDroite().getPanelUnivers().repaint();
			
		}
	}



	@Override
	public void keyReleased(KeyEvent arg0) {
		// TODO Auto-generated method stub
	}

	public void keyTyped(KeyEvent k) {}

	public Bibliotheque getSaBib() {
		return saBib;
	}

	public panelOutils getPanelOutils() {
		return panelOutils;
	}

	public TabbedpanelDroite getTabbedpanelDroite() {
		return tabbedpanelDroite;
	}



}
